package t2;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @Author admin
 * @Date 2019/4/9 14:56
 */
public class UserDaoHashset extends UserDao {
HashSet<User> hashSet=new HashSet<User>();
@Override
    public void register(User user){
    Iterator iterator=hashSet.iterator();
    while (iterator.hasNext()){
        User u=(User)iterator.next();
        if (u.getName().equals(user.getName())){
            System.out.println("注册失败");
            return;
        }
    }
    hashSet.add(user);
    System.out.println("注册成功");
}
}

